﻿using Flow.Manage.Contracts;
using Framework.Models.Request;
using Microsoft.AspNetCore.Mvc;

namespace ApprovalFlow.Api.Controllers
{
    [ApiController]
    public class LeaveTimeController : ControllerBase
    {
        private readonly ILogger<LeaveTimeController> _logger;

        private readonly IServiceProvider _provider;

        public LeaveTimeController(ILogger<LeaveTimeController> logger, IServiceProvider provider)
        {
            _logger = logger;
            _provider = provider;
        }

        private ILeaveTimeContract _leaveTimeContract => GlobalConfig.ServiceProvider.GetRequiredService<ILeaveTimeContract>();

        [HttpGet]
        [Route("api/LeaveTime/GetLeaveTimeList")]
        public async Task<TData<object>> GetLeaveTimeList()
        {
            return await _leaveTimeContract.GetLeaveTimeList();
        }

        [HttpPost]
        [Route("api/LeaveTime/AddLeaveTime")]
        public IActionResult AddLeaveTime([FromBody] Biz_LeaveTimeRequest request)
        {
            var result = _leaveTimeContract.AddLeaveTime(request);
            return Ok(result);
        }

        [HttpPut]
        [Route("api/LeaveTime/EditLeaveTime")]
        public IActionResult EditLeaveTime([FromBody] Biz_LeaveTimeRequest request)
        {
            return Ok("success");
        }

        [HttpDelete]
        [Route("api/LeaveTime/DelLeaveTime")]
        public IActionResult DelLeaveTime(int Id)
        {
            var result = _leaveTimeContract.DeleteLeaveTime(Id);
            return Ok(result);
        }
    }
}